package com.jacobson.huobi.mvp.presenter

import com.jacobson.core.di.annotation.ActivityScope
import com.jacobson.core.mvp.BasePresenter
import com.jacobson.huobi.common.expansion.applySchedulersIoMain
import com.jacobson.huobi.common.expansion.onRespResult
import com.jacobson.huobi.common.expansion.onResponseResult
import com.jacobson.huobi.entities.ForgetInfo
import com.jacobson.huobi.mvp.contract.ForgetContract
import javax.inject.Inject

@ActivityScope
class ForgetPresenter @Inject constructor(
    view: ForgetContract.View,
    model: ForgetContract.Model
) : BasePresenter<ForgetContract.View, ForgetContract.Model>(view, model), ForgetContract.Presenter {
    override fun getVertiCode(phone: String) {
        model.getVertiCode(phone)
            .applySchedulersIoMain()
            .onRespResult(view) { resp ->
                view?.getVertiCode(resp)
            }
    }

    override fun forgetUser(forgetInfo: ForgetInfo) {
        model.forgetUser(forgetInfo)
            .applySchedulersIoMain()
            .onResponseResult(view) { resp ->
                view?.forgetUser(resp)
            }
    }
}